package com.tiny.mirror.service.product.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tiny.mirror.basic.common.enums.IBaseEnum;
import lombok.Getter;

@Getter
public enum AppStatusEnum implements IBaseEnum<Integer> {

  ABLE(1, "正常"),
  DISABLE(0, "禁用"),
  ;

  @JsonValue
  @EnumValue
  private final Integer code;
  private final String name;

  AppStatusEnum(Integer code, String name) {
    this.code = code;
    this.name = name;
  }

  @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
  public static AppStatusEnum get(Integer code) {
    if (code == null) {
      return null;
    }
    for (AppStatusEnum e : values()) {
      if (e.code.equals(code)) {
        return e;
      }
    }
    return null;
  }

  @Override
  public Integer getActualValue() {
    return this.code;
  }
}
